#ifndef CANDEVICE_H
#define CANDEVICE_H

#include <QObject>
#define uint32 unsigned int
#define uint8 unsigned char
#define uint16 unsigned short
#define uint64 unsigned long
#define FRAMES_CNT 20

typedef struct CanDataFrame {
    uint32 uTimeFlag;
    uint8  nSendType;
    uint8  bRemoteFlag;
    uint8  bExternFlag;
    uint8  nDataLen;
    uint32 uID;
    uint8  arryData[ 8 ];
} CanDataFrame;

typedef struct CanInitConfig {
    uint8  bMode;
    uint8  nBtrType;
    uint8  dwBtr[ 4 ];
    uint32 dwAccCode;
    uint32 dwAccMask;
    uint8  nFilter;
    uint8  dwReserved;
} CanInitConfig;

class CanDevice : public QObject {
    Q_OBJECT
public:
    // explicit CanDevice( QObject* parent = nullptr );
    CanDevice( QObject* parent = nullptr ) : QObject( parent ) {}

    virtual uint32 CanDeviceOpen( uint32 dwType, uint32 dwIndex, char* pDescription = nullptr ) = 0;
    virtual uint32 CanChannelStart( uint32 dwDeviceHandle, uint32 dwType, uint32 dwIndex, uint32 dwChannel, CanInitConfig* pInitConfig ) = 0;
    virtual uint32 CanChannelStopDeviceClose( uint32 dwDeviceHandle, uint32 dwType, uint32 dwIndex, uint32 dwChannel ) = 0;
    virtual uint64 CanChannelSend( uint32 dwDeviceHandle, uint32 dwType, uint32 dwIndex, uint32 dwChannel, CanDataFrame* frame, uint64 nCount ) = 0;
    virtual uint64 CanChannelReceive( uint32 dwDeviceHandle, uint32 dwType, uint32 dwIndex, uint32 dwChannel, CanDataFrame* pReceive, uint64 nCount, int nWaitTime ) = 0;
signals:
};

#endif  // CANDEVICE_H
